#Region " Imports "

Imports Microsoft.VisualBasic
Imports System
Imports System.Data
Imports System.Configuration
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls

#End Region

Public Class MembershipUtility

    Public Function GetUser(ByVal Username As String) As MembershipUser
        Return Membership.GetUser(Username)
    End Function

    Public Function GetUser(ByVal UserID As Guid) As MembershipUser
        Return Membership.GetUser(UserID)
    End Function

    Public Function DeleteUser(ByVal Username As String) As Boolean
        Return Membership.DeleteUser(Username)
    End Function

    Public Function GetAllUsers() As DataSet
        Dim mu As MembershipUserCollection
        Dim dsMembership As New DataSet("Membership")
        Dim dtUsers As DataTable
        dtUsers = dsMembership.Tables.Add("Users")
        dtUsers.Columns.Add("IsOnline", Type.GetType("System.Boolean"))
        dtUsers.Columns.Add("UserName", Type.GetType("System.String"))
        dtUsers.Columns.Add("PasswordQuestion", Type.GetType("System.String"))
        dtUsers.Columns.Add("IsLockedOut", Type.GetType("System.Boolean"))
        dtUsers.Columns.Add("Email", Type.GetType("System.String"))
        dtUsers.Columns.Add("CreationDate", Type.GetType("System.DateTime"))
        dtUsers.Columns.Add("LastLoginDate", Type.GetType("System.DateTime"))
        dtUsers.Columns.Add("LastLockoutDate", Type.GetType("System.DateTime"))
        dtUsers.Columns.Add("LastActivityDate", Type.GetType("System.DateTime"))
        dtUsers.Columns.Add("LastPasswordChangedDate", Type.GetType("System.DateTime"))
        dtUsers.Columns.Add("IsApproved", Type.GetType("System.Boolean"))
        mu = Membership.GetAllUsers

        Dim u As MembershipUser

        For Each u In mu
            Dim r As DataRow
            r = dtUsers.NewRow()
            r("IsOnline") = u.IsOnline
            r("UserName") = u.UserName
            r("PasswordQuestion") = u.PasswordQuestion
            r("IsLockedOut") = u.IsLockedOut
            r("Email") = u.Email
            r("CreationDate") = u.CreationDate
            r("LastLoginDate") = u.LastLoginDate
            r("LastLockoutDate") = u.LastLoginDate
            r("LastActivityDate") = u.LastLoginDate
            r("LastPasswordChangedDate") = u.LastPasswordChangedDate
            r("IsApproved") = u.IsApproved
            dtUsers.Rows.Add(r)
        Next

        Return dsMembership

    End Function

End Class